import axios from '@/utils/axios';

export const getPriceReducePage = (params) => {
    return axios.request({
        url: '/market/price-reduce/page',
        method: 'get',
        params
    });
};

export const getProductPage = (params) => {
    return axios.request({
        url: '/market/price-reduce/product/page',
        method: 'get',
        params
    });
};

export const addPriceReduce = (data) => {
    return axios.request({
        url: '/market/price-reduce',
        method: 'post',
        data
    });
};

export const getPriceReduce = (id) => {
    return axios.request({
        url: '/market/price-reduce/' + id,
        method: 'get'
    });
};

export const deletePriceReduce = (id) => {
    return axios.request({
        url: '/market/price-reduce/' + id,
        method: 'delete'
    });
};

export const endPriceReduce = (id) => {
    return axios.request({
        url: '/market/price-reduce/' + id + '/end',
        method: 'put'
    });
};

export const getPriceReduceProduct = (id) => {
    return axios.request({
        url: '/market/price-reduce/' + id + '/product',
        method: 'get'
    });
};

export const editPriceReduce = (data) => {
    return axios.request({
        url: '/market/price-reduce/',
        method: 'put',
        data
    });
};

// 信用卡支付优惠
export const creditDiscount = (data) => {
    return axios.request({
        url: '/market/credit-discount',
        method: 'post',
        data
    });
};

export const getCreditDiscount = (siteId) => {
    return axios.request({
        url: `/market/credit-discount/${siteId}`,
        method: 'get'
    });
};
